#include "stdafx.h"
#include "ASAbstractWidget.h"

ASAbstractWidget::ASAbstractWidget(QWidget *parent)
	: QWidget(parent)
{
	m_pScrollArea = new QScrollArea(this);
}

ASAbstractWidget::~ASAbstractWidget()
{

}

void	ASAbstractWidget::layout(QWidget* pParent)
{
	pParent->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Expanding);
	pParent->setMinimumWidth(pParent->width()+10);

	
	m_pScrollArea->setGeometry(0,0,pParent->width()+20,pParent->height());
	m_pScrollArea->setMinimumWidth(pParent->width()+20);
	QHBoxLayout*	hboxlayout = new QHBoxLayout(this);
	m_pScrollArea->setWidget(pParent);
	hboxlayout->addStretch(3);
	hboxlayout->addWidget(m_pScrollArea);
	hboxlayout->addStretch(3);
	hboxlayout->setContentsMargins(2,2,2,2);
	hboxlayout->setSpacing(0);
	this->setLayout(hboxlayout);
	m_pScrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);

	connect(m_pScrollArea->verticalScrollBar(),SIGNAL(valueChanged(int)),this,SIGNAL(onVerScrollMovedSignal(int)));
}

void ASAbstractWidget::setScrollValue( int nVal )
{
	m_pScrollArea->verticalScrollBar()->setValue(nVal);
}
